<style scope>
.main-container{
    background-color: #f3f5fa;
}
</style>
<style>
.bankInfo, .content{
    background-color: #f3f5fa;
}

.bankInfo .father{
    margin: 3px;
    display: inline-block;
    vertical-align:bottom;
}

.bankInfo .logo{
    width: 180px;
    height: 180px;
    margin-bottom: 2px;
    border-radius: 5px 5px 0 0;
    overflow: hidden;
}

.bankInfo .img{
    width: 100%;
    height: 100%;
}

.bankInfo .createActivity, .bankInfo .remove{
    display: inline-block;
    width: calc((180px - 2px) / 2);
    height: 50px;
    line-height: 50px;
    background-color: #ffffff;
    text-align: center;
}

.bankInfo .other{
    width: 186px;
    height: 232px;
    line-height: 228px;
    border: 2px solid #eaecef;
    position: relative;
}

.bankInfo .other:hover, .bankInfo .createActivity, .bankInfo .remove{
    cursor: pointer;
}

.bankInfo .createActivity{
    margin-right: 2px;
    border-radius: 0 0 0 5px;
}

.bankInfo .remove{
    margin-right: 2px;
    border-radius: 0 0 5px 0;
}

.bankInfo .add{
    background-color: #d3d9e2;
    position: absolute;
}

.bankInfo .add:nth-child(1){
    width: 6px;
    height: 27px;
    border-radius: 2px 2px 0 0;
    left: 88px;
    top: 84px;
}

.bankInfo .add:nth-child(2){
    width: 27px;
    height: 6px;
    border-radius: 2px 0 0 2px;
    left: 61px;
    top: 111px;
}

.bankInfo .add:nth-child(3){
    width: 6px;
    height: 6px;
    left: 88px;
    top: 111px;
}

.bankInfo .add:nth-child(4){
    width: 27px;
    height: 6px;
    border-radius: 0 2px 2px 0;
    left: 94px;
    top: 111px;
}

.bankInfo .add:nth-child(5){
    width: 6px;
    height: 27px;
    border-radius: 0 0 2px 2px;
    left: 88px;
    top: 114px;
}
</style>
<template>
  <div class="app-container bankInfo" style="height:100%;">
    <div class="content">
        <div v-for="(d,index) in bankList" :key="index" class="father">
            <router-link :to="{path:'/bank/activity/list',query:{no:bankList[index].no}}">
                <div class="logo"><img class="img" :src="bankList[index].logo" alt=""></div>
            </router-link>
            <router-link v-if="bankList[index].examineResult == 1" :to="{name:'activityInfoAdd',params:{merchantNo:bankList[index].no,merchantName:bankList[index].cnName}}">
                <div class="createActivity">创建活动</div>
            </router-link>
            <div v-if="bankList[index].examineResult != 1" class="createActivity" style="cursor:not-allowed;color:#C0C4CC;">创建活动</div>
            <div class="remove" @click="handleDelete(bankList[index])">移除</div>
        </div>
        <router-link :to="{name:'merchantBasicEdit',params:{type:1}}">
            <div class="father other" style="background-color:#f5f5f5;">
                <div class="add"></div>
                <div class="add"></div>
                <div class="add"></div>
                <div class="add"></div>
                <div class="add"></div>
            </div>
        </router-link>
    </div>

    <!-- 添加或修改银行管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="商户编号" prop="no">
          <el-input v-model="form.no" placeholder="请输入商户编号" />
        </el-form-item>
        <el-form-item label="商户中文名称" prop="cnName">
          <el-input v-model="form.cnName" placeholder="请输入商户中文名称" />
        </el-form-item>
        <el-form-item label="商户简称" prop="shortName">
          <el-input v-model="form.shortName" placeholder="请输入商户简称" />
        </el-form-item>
        <el-form-item label="商户英文名称" prop="enName">
          <el-input v-model="form.enName" placeholder="请输入商户英文名称" />
        </el-form-item>
        <el-form-item label="商户类型" prop="type">
          <el-select v-model="form.type" placeholder="请选择商户类型">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="商户主营产品" prop="mainProduct">
          <el-input v-model="form.mainProduct" placeholder="请输入商户主营产品" />
        </el-form-item>
        <el-form-item label="商户状态,1正常,2弃用,3再次审核中,4过期">
          <el-radio-group v-model="form.status">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="商户LOGO" prop="logo">
          <el-input v-model="form.logo" placeholder="请输入商户LOGO" />
        </el-form-item>
        <el-form-item label="商户官网地址" prop="url">
          <el-input v-model="form.url" placeholder="请输入商户官网地址" />
        </el-form-item>
        <el-form-item label="协议编号" prop="meanNo">
          <el-input v-model="form.meanNo" placeholder="请输入协议编号" />
        </el-form-item>
        <el-form-item label="营业执照资料编号" prop="businessDataNo">
          <el-input v-model="form.businessDataNo" placeholder="请输入营业执照资料编号" />
        </el-form-item>
        <el-form-item label="卫生许可证资料编号" prop="hygienicDataNo">
          <el-input v-model="form.hygienicDataNo" placeholder="请输入卫生许可证资料编号" />
        </el-form-item>
        <el-form-item label="食品安全证资料编号" prop="foodSafetyDataNo">
          <el-input v-model="form.foodSafetyDataNo" placeholder="请输入食品安全证资料编号" />
        </el-form-item>
        <el-form-item label="健康证资料编号" prop="healthDataNo">
          <el-input v-model="form.healthDataNo" placeholder="请输入健康证资料编号" />
        </el-form-item>
        <el-form-item label="开户许可证资料编号" prop="accountOpeningDataNo">
          <el-input v-model="form.accountOpeningDataNo" placeholder="请输入开户许可证资料编号" />
        </el-form-item>
        <el-form-item label="商户入驻开始日期" prop="settledStartDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.settledStartDate"
            type="date"
            value-format="yyyyMMdd"
            placeholder="选择商户入驻开始日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="商户入驻结束日期" prop="settledEndDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.settledEndDate"
            type="date"
            value-format="yyyyMMdd"
            placeholder="选择商户入驻结束日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="审核编号" prop="examineCode">
          <el-input v-model="form.examineCode" placeholder="请输入审核编号" />
        </el-form-item>
        <el-form-item label="创建人" prop="buildOperator">
          <el-input v-model="form.buildOperator" placeholder="请输入创建人" />
        </el-form-item>
        <el-form-item label="创建日期" prop="buildDate">
          <el-input v-model="form.buildDate" placeholder="请输入创建日期" />
        </el-form-item>
        <el-form-item label="创建时间" prop="buildTime">
          <el-input v-model="form.buildTime" placeholder="请输入创建时间" />
        </el-form-item>
        <el-form-item label="最后修改人" prop="modifiedOperator">
          <el-input v-model="form.modifiedOperator" placeholder="请输入最后修改人" />
        </el-form-item>
        <el-form-item label="最后修改日期" prop="modifiedDate">
          <el-input v-model="form.modifiedDate" placeholder="请输入最后修改日期" />
        </el-form-item>
        <el-form-item label="最后修改时间" prop="modifiedTime">
          <el-input v-model="form.modifiedTime" placeholder="请输入最后修改时间" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listBank, getBank, delBank, addBank, updateBank, exportBank, listBankVo, logicRemoveBankByNos } from "@/api/bank/info";

export default {
  name: "Bank",
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 选中数组
      nos: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 银行管理表格数据
      bankList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        no: null,
        cnName: null,
        shortName: null,
        enName: null,
        type: null,
        mainProduct: null,
        status: null,
        logo: null,
        url: null,
        meanNo: null,
        businessDataNo: null,
        hygienicDataNo: null,
        foodSafetyDataNo: null,
        healthDataNo: null,
        accountOpeningDataNo: null,
        settledStartDate: null,
        settledEndDate: null,
        examineCode: null,
        buildOperator: null,
        buildDate: null,
        buildTime: null,
        modifiedOperator: null,
        modifiedDate: null,
        modifiedTime: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询银行管理列表 */
    getList() {
      this.loading = true;
      listBankVo(this.queryParams).then(response => {
        this.bankList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        no: null,
        cnName: null,
        shortName: null,
        enName: null,
        type: null,
        mainProduct: null,
        status: "0",
        logo: null,
        url: null,
        meanNo: null,
        businessDataNo: null,
        hygienicDataNo: null,
        foodSafetyDataNo: null,
        healthDataNo: null,
        accountOpeningDataNo: null,
        settledStartDate: null,
        settledEndDate: null,
        examineCode: null,
        buildOperator: null,
        buildDate: null,
        buildTime: null,
        modifiedOperator: null,
        modifiedDate: null,
        modifiedTime: null,
        examineResult: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加银行管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getBank(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改银行管理";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateBank(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addBank(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const nos = row.no || this.nos;
      this.$confirm('是否确认删除银行管理编号为"' + nos + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return logicRemoveBankByNos(nos);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有银行管理数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportBank(queryParams);
        }).catch(() => {});
    }
  }
};
</script>
